package cz.ctu.android.DriveCommunicator.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.graphics.drawable.Drawable;

import cz.ctu.android.DriveCommunicator.utils.DriverConstants.Users;





public class Zprava {
	
	private int id;
	private int senderID = DriverConstants.myId;
	private String jmeno;
	private String prijmeni;
	private int cisloFotky;
	// adresat, prijemnce
	private Typ typ;
	private boolean prectena;
	//yyyy/MM/dd HH.mm.ss
	private String date;
	private String zprava;	
	
	// cely constructor
		public Zprava(int id, Users user,Typ typ, boolean prectena, String zprava) {
			super();
			this.id = id;
			this.senderID = user.getID();
			this.jmeno = user.getJmeno();
			this.prijmeni = user.getPrijmeni();
			this.typ = typ;
			this.prectena = prectena;
			this.zprava = zprava;
			

			DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	        Date dat = new Date();
	        this.date =  dateFormat.format(dat);
		}
	
	// cely constructor
	public Zprava(int id, Users user,Typ typ, boolean prectena,String date, String zprava) {
		super();
		this.id = id;
		this.senderID = user.getID();
		this.jmeno = user.getJmeno();
		this.prijmeni = user.getPrijmeni();
		this.typ = typ;
		this.prectena = prectena;
		this.zprava = zprava;
		

		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date dat = new Date();
        this.date =  dateFormat.format(dat);
	}
	
	public Zprava(int id, String zprava) {
		super();
		this.id = id;
		this.senderID = DriverConstants.myId;
		this.typ = Typ.PRIJEMCE;
		this.prectena = true;
		this.zprava = zprava;
		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date dat = new Date();
        this.date =  dateFormat.format(dat);
	}
	
	/*
	 * Prida sam aktualni datum
	 */
	//public Zprava(int id, String jmeno, String prijmeni, int cisloFotky,
	//		Typ typ, boolean prectena, String zprava) {
		//(super();
		//this.id = id;
	//this.jmeno = jmeno;
	//this.prijmeni = prijmeni;
	//this.cisloFotky = cisloFotky;
	//this.typ = typ;
		//this.prectena = prectena;
		
	//DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	//  Date dat = new Date();
	//  this.date =  dateFormat.format(dat);
	//	this.zprava = zprava;
	//}


	public int getId() {
		return id;
	}

	public String getJmeno() {
		return jmeno;
	}


	public void setJmeno(String jmeno) {
		this.jmeno = jmeno;
	}


	public String getPrijmeni() {
		return prijmeni;
	}


	public void setPrijmeni(String prijmeni) {
		this.prijmeni = prijmeni;
	}


	public int getCisloFotky() {
		return cisloFotky;
	}


	public void setCisloFotky(int cisloFotky) {
		this.cisloFotky = cisloFotky;
	}


	public Typ getTyp() {
		return typ;
	}


	public void setTyp(Typ typ) {
		this.typ = typ;
	}


	public boolean isPrectena() {
		return prectena;
	}
	
	public int getSenderID(){
	    return senderID;
		
	}


	public void setPrectena(boolean prectena) {
		this.prectena = prectena;
	}


	public String getDate() {
		return date;
	}


	public void setDate(String date) {
		this.date = date;
	}


	public String getZprava() {
		return zprava;
	}


	public void setZprava(String zprava) {
		this.zprava = zprava;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + cisloFotky;
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result + id;
		result = prime * result + ((jmeno == null) ? 0 : jmeno.hashCode());
		result = prime * result + (prectena ? 1231 : 1237);
		result = prime * result
				+ ((prijmeni == null) ? 0 : prijmeni.hashCode());
		result = prime * result + ((typ == null) ? 0 : typ.hashCode());
		result = prime * result + ((zprava == null) ? 0 : zprava.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Zprava other = (Zprava) obj;
		if (cisloFotky != other.cisloFotky)
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (id != other.id)
			return false;
		if (jmeno == null) {
			if (other.jmeno != null)
				return false;
		} else if (!jmeno.equals(other.jmeno))
			return false;
		if (prectena != other.prectena)
			return false;
		if (prijmeni == null) {
			if (other.prijmeni != null)
				return false;
		} else if (!prijmeni.equals(other.prijmeni))
			return false;
		if (typ == null) {
			if (other.typ != null)
				return false;
		} else if (!typ.equals(other.typ))
			return false;
		if (zprava == null) {
			if (other.zprava != null)
				return false;
		} else if (!zprava.equals(other.zprava))
			return false;
		return true;
	}

	
}

enum Typ {
	ODESILATEL, PRIJEMCE;
}
